package com.example.trafficexam2.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;

import com.example.trafficexam2.R;
import com.example.trafficexam2.RegularBusNextActivity;

/**
 * Created by Administrator on 2018/11/22/022.
 */

public class RegularBusFragment extends Fragment {
    View view;
    private ListView buslist;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.regularbus_fragment, container, false);
        initView();
        initdata();
        return view;
    }

    private void initView(){
        buslist = view.findViewById(R.id.bus_list);
        buslist.setAdapter(new BaseAdapter() {
            @Override
            public int getCount() {
                return 4;
            }

            @Override
            public Object getItem(int i) {
                return i;
            }

            @Override
            public long getItemId(int i) {
                return 0;
            }

            @Override
            public View getView(int i, View view, ViewGroup viewGroup) {
                View view1= LayoutInflater.from(getContext()).inflate(R.layout.regular_bus_item,null);
                return view1;
            }
        });
        buslist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent intent = new Intent(getContext(),RegularBusNextActivity.class);
                startActivity(intent);
            }
        });
    }

    private void initdata(){

    }
}
